# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer:
pkgname=mdcat
pkgver=0.27.1
pkgrel=0
pkgdesc="Cat for markdown"
url="https://codeberg.org/flausch/mdcat"
# s390x, limited by cargo
# ppc64le fails to build 'ring v0.16.19'
arch="all !s390x !ppc64le !riscv64"
license="Apache-2.0"
makedepends="asciidoctor cargo shared-mime-info openssl-dev"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-zsh-completion
	$pkgname-fish-completion
	"
source="https://codeberg.org/flausch/mdcat/archive/mdcat-$pkgver.tar.gz
	minimize-size.patch
	"
builddir="$srcdir"/mdcat

prepare() {
	default_prepare
	cargo fetch --locked
}

build() {
	cargo build --release --frozen
}

check() {
	cargo test --frozen
}

package() {
	install -s -Dm0755 target/release/mdcat -t "$pkgdir"/usr/bin

	# Install the generated shell completion files
	install -Dm644 target/release/build/mdcat-*/out/mdcat.bash \
		-t "$pkgdir"/usr/share/bash-completion/completions
	install -Dm644 target/release/build/mdcat-*/out/_mdcat \
		-t "$pkgdir"/usr/share/zsh/site-functions
	install -Dm644 target/release/build/mdcat-*/out/mdcat.fish \
		-t "$pkgdir"/usr/share/fish/completions

	# Install the generated man-page
	install -Dm644 "$builddir"/target/release/build/mdcat-*/out/mdcat.1 \
		-t "$pkgdir"/usr/share/man/man1/
}

sha512sums="
61fbab4c247473f041fd116fcfaf107a78ade3ae0bc567972008eb50b4e06bba29ba6b6baab5ed14336b9ae6d932065d75860b9f69fea7a7e895205bb0d74522  mdcat-0.27.1.tar.gz
457cbc306ba65fe09c5304c7cd89ccbaeeeec29ca7c54e84e610de1256fffd37391f2d3fe592aed061d425d6092d50a8277d33f7b3143714d70ad500654a926d  minimize-size.patch
"
